<template>
  <div class="shopPage">
    <div class="head">
      <van-icon name="arrow-left" color="#fff" class="back" @click="b.back" />
      <div class="hotTitle"></div>
    </div>
    <div class="panel">
      <div class="avatarBox">
        <div class="shopName ell">店主</div>
        <van-image round :src="info.wx_headpic" class="avatar" fit="cover" />
      </div>
      <div class="infoBox">
        <p class="shopName2">{{ info.shop_name || info.member_list_username }}</p>
        <van-text-ellipsis :content="info.shop_address" class="address" rows="2" />
      </div>
      <div class="qrcodeBox" @click="show = true">
        <van-image :src="`${globe.staticDomain}/${info.wx_qrcode}`" class="qrcode" fit="cover" />
        <p>添加微信</p>
      </div>
    </div>
    <div class="tit1"></div>
    <!-- 店铺环境 -->
    <swiper class="my-swipe" :modules="modules" :loop="true" :pagination="{type:'fraction'}" :centered-slides="true"
      :navigation="true" effect="creative" :creative-effect="effect" slides-per-view="auto">
      <swiper-slide class="slide" v-for="item in info.shop_images" :key="item.id">
        <van-image :src="`${globe.staticDomain}/${item.image}`" fit="cover" class="img" />
        <div class="state flexCenter" v-if="item.state!=1">{{ transState(item.state) }}</div>
      </swiper-slide>
      <template v-if="info.shop_images.length==0">
        <swiper-slide class="slide" v-for="i in 4" :key="i">
          <van-image :src="getImgUrl('noimg.jpg')" fit="cover" class="img" />
        </swiper-slide>
      </template>
    </swiper>
    <div class="tit2"></div>
    <!-- 荣誉称号 -->
    <ul class="honner">
      <li v-for="h in info.shop_honors">{{h}}</li>
    </ul>
    <!-- 荣誉证书 -->
    <div class="certGroup flexCenter">
      <div class="certBox" v-for="item in info.honor_images" :key="item.id">
        <van-image :src="`${globe.staticDomain}/${item.image}`" class="cert" fit="cover" />
        <div class="state flexCenter" v-if="item.state != 1">{{ transState(item.state) }}</div>
      </div>
      <template v-if="info.honor_images.length == 0">
        <div class="certBox" v-for="i in 3" :key="i">
          <van-image :src="getImgUrl('noimg.jpg')" class="cert" fit="cover" />
        </div>
      </template>
      <div class="stack"></div>
    </div>
    <div class="banner"></div>
    <div class="bottomSlogn"></div>
  </div>
  <!-- 用户二维码 -->
  <van-dialog v-model:show="show" title="店主专属微信" confirmButtonText="关闭">
    <van-image class="qrcodeImg" :src="`${globe.staticDomain}/${info.wx_qrcode}`" fit="cover" />
  </van-dialog>
</template>

<script setup>
import { useUserStore, useGlobeStore } from "@/stores";
import { storeToRefs } from 'pinia'
import { Pagination, EffectCreative } from 'swiper/modules'
import { Swiper, SwiperSlide } from 'swiper/vue'
import { getImgUrl } from '@/utils/helper'
import useBack from '@/hooks/back';
import 'swiper/css'
import 'swiper/css/pagination'

const b = useBack();
const user = useUserStore()
const globe = useGlobeStore();
const { info } = storeToRefs(user)
const show = ref(false);
const modules = [Pagination, EffectCreative]
const effect = {
  prev: {
    shadow: true,
    translate: ['-107%', 0, -110],
  },
  next: {
    shadow: true,
    translate: ['107%', 0, -110],
  }
}
function transState(state){
  switch (state) {
    case 0:
      return "加急审核中"
    case -1:
      return "审核拒绝"
  }
}
onMounted(()=>{
  if (user.i) user.queryReference()
})
</script>

<style lang="less" scoped>
.shopPage{
  background-color: red;
  background-image: url("@/assets/img/bg2.png"), url("@/assets/img/bg3.png");
  background-repeat: no-repeat;
  background-position: center 0, center 185px;
  background-size: 100% auto;
  min-height: 935px;
  --van-nav-bar-background: transparent;
  padding-top: 45px;
  overflow: hidden;
  .head{
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 44px;
    .hotTitle {
      width: 240px;
      height: 30px;
      background: url("@/assets/img/hotTitle.png");
      background-size: cover;
      margin-left: 10px;
    }
    .back {
      font-size: 20px;
      position: absolute;
      top: 50%;
      left: 10px;
      transform: translateY(-50%);
    }
  }
  .tit1{
    width: 109px;
    height: 45px;
    background: url("@/assets/img/example_tit1.png");
    background-size: cover;
    margin: 16px auto 20px;
  }
  .panel{
    width: 343px;
    height: 92px;
    background-color: rgba(255, 231, 214, 0.92);
    backdrop-filter: blur(8px);
    margin: 19px auto 0;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    border: 1px solid #fff;
    .avatarBox{
      width: 64px;
      height: 80px;
      background-image: url("@/assets/img/avatarBox.png");
      background-repeat: no-repeat;
      background-size: cover;
      margin-left: 16px;
      margin-right: 12px;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding-top: 12px;
    }
    .avatar{
      width: 40px;
      height: 40px;
    }
    .shopName{
      width: 58px;
      text-align: center;
      font-size: 10px;
      color: #FFEBAD;
    }
    .infoBox{
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      color: #141414;
      .shopName2{
        font-size: 18px;
        line-height: 1.2;
      }
      .address{
        font-size: 14px;
        line-height: 1.2;
        margin-top: 6px;
      }
    }
    .qrcodeBox{
      width: 64px;
      height: 100%;
      background-color: #FFE7D6;
      backdrop-filter: blur(8px);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      margin-left: 10px;
      .qrcode{
        width: 43px;
        height: 43px;
        margin-bottom: 10px;
      }
      p{
        font-size: 10px;
        color: #141414;
        font-weight: 900;
      }
    }
  }
  .my-swipe{
    width: 100%;
    height: 180px;
    .slide{
      width: 330px !important;
      color: #fff;
      font-size: 20px;
      line-height: 150px;
      text-align: center;
      background-color: #EB2525;
      border: 1px solid #FFEBAD;
      border-radius: 12px;
      padding: 8px;
      overflow: hidden;
      position: relative;
      .img{
        width: 100%;
        height: 100%;
        border-radius: 10px;
        overflow: hidden;
      }
    }
    :deep(.swiper-pagination){
      width: 36px;
      height: 20px;
      border-radius: 10px;
      background: rgba(20, 20, 20, 0.4);
      color: #fff;
      font-size: 12px;
      display: flex;
      justify-content: center;
      align-items: center;
      line-height: 1;
      right: 28px;
      left: auto;
    }
  }
  .tit2 {
    width: 92px;
    height: 16px;
    background: url("@/assets/img/example_tit2.png");
    background-size: cover;
    margin: 26px auto 16px;
  }
  .honner{
    width: 100%;
    height: 20px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    overflow-x: scroll;
    padding: 0 10px;
    li{
      flex-shrink: 0;
      display: inline-block;
      height: 20px;
      line-height: 20px;
      background-image: linear-gradient(45deg, #FFEBAD, #FFDF80);
      color: #141414;
      font-size: 10px;
      border-radius: 4px;
      padding: 0 8px;
      margin: 0 2px;
    }
  }
  .certGroup{
    width: 100%;
    position: relative;
    height: 70px;
    .certBox{
      position: relative;
      z-index: 1;
      margin: 0 5px;
      border-radius: 4px;
      overflow: hidden;
      border: 1px solid #FFDF80;
      .state {
        font-size: 14px !important;
      }
    }
    .cert {
      display: block;
      width: 104px;
      height: 70px;
      padding: 4px;
      background-color: #EB2525;
      :deep(img) {
        border-radius: 4px;
        overflow: hidden;
      }
    }
    .stack{
      width: 386px;
      height: 48px;
      background: url("@/assets/img/stack.png");
      background-size: cover;
      position: absolute;
      bottom: -35px;
      left: 50%;
      transform: translateX(-50%);
    }
  }
  .banner{
    width: 343px;
    height: 172px;
    margin: 46px auto 40px;
    background: url("@/assets/img/banner.png") center no-repeat;
    background-size: contain;
  }
  .bottomSlogn{
    width: 144px;
    height: 24px;
    background: url("@/assets/img/slogan.png") center no-repeat;
    background-size: contain;
    margin: 0 auto;
  }
  .state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    // backdrop-filter: blur(5px);
    color: rgba(29, 33, 41, 1);
    font-size: 18px;
  }
}
.qrcodeImg {
  display: block;
  margin: 20px auto;
  width: 120px;
  height: 120px;
}
</style>
